package com.atlassian.extras.decoder.api;

import com.atlassian.extras.common.LicenseException;
import java.util.Properties;

public abstract class AbstractLicenseDecoder implements LicenseDecoder {
    @Override
    public final Properties decode(String licenseString) throws LicenseException {
        Properties licenseProperties = doDecode(licenseString);
        if (licenseProperties == null) {
            throw new RuntimeException("Invalid License - an error occurred when decoding the license");
        }
        licenseProperties.setProperty("licenseVersion", String.valueOf(getLicenseVersion()));
        return licenseProperties;
    }

    protected abstract Properties doDecode(String paramString) throws LicenseException;

    protected abstract int getLicenseVersion();
}
